/*
 * Copyright (c) 2011, Brookhaven National Laboratory
 * All rights reserved.
 * The software in this package is published under the terms
 * of the BSD license a copy of which has been included with
 * this distribution in the license.txt file.
 */

#include <dds/xtypes/TypeObject.hpp>

#include <tdds/xtypes/DynamicTypeFactory.hpp>
#include <tdds/xtypes/DynamicType.hpp>

#include "dds/type/dynamic/detail/DynamicTypeFactory.h"
#include "dds/type/dynamic/detail/DynamicType.h"

#include "oxtypes/delegate/DynamicType.h"
#include "oxtypes/impl/DynamicTypeManagerImpl.h"

typedef dds::type::dynamic::detail::DynamicTypeFactory DTF;


namespace tdds { namespace type { namespace dynamic {

DynamicTypeFactory <DTF> singleton_;
oxtypes::impl::DynamicTypeManagerImpl* tregistry_ = 0;

template <> DynamicTypeFactory <DTF>
DynamicTypeFactory <DTF>::get_instance() {
  if(tregistry_ == 0) {
    tregistry_ = oxtypes::impl::DynamicTypeManagerImpl::getInstance();  
  }
  return singleton_;
}

template <> void
DynamicTypeFactory <DTF>::close() {
 throw dds::core::UnsupportedError("");
}

template <> dds::type::dynamic::DynamicType
DynamicTypeFactory <DTF>::primitive_type(dds::type::TypeKind kind) const{
  return tregistry_->getPrimitiveType(kind);
}

template <> dds::type::dynamic::DynamicType
DynamicTypeFactory<DTF>::type(
  const dds::type::dynamic::TypeDescriptor& descriptor){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType
DynamicTypeFactory<DTF>::string_type(dds::type::Bound bound){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType
DynamicTypeFactory<DTF>::wstring_type(dds::type::Bound bound){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType
DynamicTypeFactory<DTF>::sequence_type(
      const dds::type::dynamic::DynamicType& element_type,
      dds::type::Bound bound){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType
DynamicTypeFactory<DTF>::array_type(
        const dds::type::dynamic::DynamicType& element_type,
	const dds::type::BoundSeq& bound){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType 
DynamicTypeFactory<DTF>::map_type(
        const dds::type::dynamic::DynamicType& key_element_type,
	const dds::type::dynamic::DynamicType& element_type,
	dds::type::Bound bound){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType
DynamicTypeFactory<DTF>::bitset_type(dds::type::Bound bound){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType 
DynamicTypeFactory<DTF>::load_type_from_url(
	 const std::string& document_url,
	 const std::string& type_name,
	 const dds::type::dynamic::IncludePathSeq& include_paths){
    throw dds::core::UnsupportedError("");
}

template<> dds::type::dynamic::DynamicType 
DynamicTypeFactory<DTF>::load_type_from_document(
         const std::string& document,
	 const std::string& type_name,
	 const dds::type::dynamic::IncludePathSeq& include_paths){
    throw dds::core::UnsupportedError("");
}

}}}
